import axios from '@/libs/request/axios'
import QS from 'qs';

// 获取全部角色数据
export const getAllRoleList = (businessType) => {
    return axios.request({
        url: '/admin/applyRole/getAllList',
        data: QS.stringify({businessType:businessType},{arrayFormat: 'repeat'}),
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'post'
    })
}
// 获取渠道
export const getApplyAllList = (businessType) => {
    return axios.request({
        url: '/admin/applyRole/getApplyAllList',
        data: QS.stringify({businessType:businessType},{arrayFormat: 'repeat'}),
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'post'
    })
}

// 获取全部渠道角色数据
export const getMatchingRole = (businessType) => {
    return axios.request({
        url: '/admin/applyRole/getMatchingRole',
        data: QS.stringify({businessType:businessType},{arrayFormat: 'repeat'}),
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'post'
    })
}
// 分页获取角色数据
export const getRoleList = (params) => {
    return axios.request({
        url: '/admin/applyRole/getAllByPage',
        data: QS.stringify({pageNumber:params.pageNumber,pageSize:params.pageSize},{arrayFormat: 'repeat'}),
        method: 'post',
        headers: { 'content-type': 'application/x-www-form-urlencoded' },

    })
}
// 添加角色
export const addRole = (params) => {
    return axios.request({
        url: '/admin/applyRole/add',
        data: params,
        method: 'post'
    })
}
// 编辑角色
export const editRole = (params) => {
    return axios.request({
        url: '/admin/applyRole/edit',
        data: params,
        method: 'post'
    })
}

// 分配角色权限
export const editRolePerm = (params) => {
    return axios.request({
        url: '/admin/applyRole/editRolePerm',
        data: params,
        method: 'post'
    })
}
// 分配角色数据权限
export const editRoleDep = (params) => {
    return axios.request({
        url: '/admin/applyRole/editRoleDep',
        data: params,
        method: 'post'
    })
}
// 删除角色
export const deleteRole = (ids, params) => {
    return axios.request({
        url: `/admin/applyRole/delAllByIds/${ids}`,
        params: params,
        method: 'delete'
    })
}

export const getUserRole = () => {
    return axios.request({
        url: '/admin/applyRole/getUserRole',
        data: QS.stringify({},{arrayFormat: 'repeat'}),
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'post'
    })
}

export const getUserPower = (params) => {
    return axios.request({
        url: '/admin/applyRole/getUserPower',
        data: params,
        method: 'post'
    })
}

export const getCommissionLoan = (businessType) => {
    return axios.request({
        url: '/admin/applyRole/getCommissionLoan',
        data: QS.stringify({},{arrayFormat: 'repeat'}),
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'post'
    })
}
